<?php

use Workerman\Timer;

class Mail
{
    private $timer_id;
    public function send($to, $subject){
        echo 'send mail...\n';
    }

    public function sendLater($interval,$to,$content){
        //回调方法当前类
        Timer::add($interval, array($this, 'send'), array($to, $content),false);
    }

    //定时发送邮件
    public function sendTimer($interval,$to,$content){
        $this->timer_id = Timer::add($interval,array($this,'send'),array($to,$content),true);
    }

    //停止定时发送邮件
    public function clearTimer(){
        Timer::del($this->timer_id);
    }
}